package com.jinmdz.fmis.dao.dao;

import com.jinmdz.fmis.dao.dao.provider.ChargeSettleProvider;
import com.jinmdz.fmis.dao.model.settlement.ChargeSettleViewItem;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 费用结算Dao
 *
 * @author LiCongLu
 * @date 2020-02-19 11:45
 */
public interface ChargeSettleDao {

    /**
     * 获取最后一个费用结算批次编号
     *
     * @param
     * @return
     * @author LiCongLu
     * @date 2020-02-21 11:35
     */
    @Select(" select settle_batch_no from charge_settle order by id desc limit 1 ")
    @ResultType(String.class)
    String getSettleBatchNoAsLast();

    /**
     * 按照主键获取费用结算信息
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-02-21 15:35
     */
    @SelectProvider(type = ChargeSettleProvider.class, method = "getChargeSettleViewById")
    ChargeSettleViewItem getChargeSettleViewById(@Param("id") Integer id);

    /**
     * 按照业务编码获取结算信息
     *
     * @param businessCode     业务编码
     * @param invoiceStateCode 作废发票编码
     * @return
     * @author LiCongLu
     * @date 2020-02-21 14:41
     */
    @SelectProvider(type = ChargeSettleProvider.class, method = "listChargeSettleViewByBusinessCode")
    ArrayList<ChargeSettleViewItem> listChargeSettleViewByBusinessCode(@Param("businessCode") String businessCode, @Param("invoiceStateCode") Integer invoiceStateCode);

    /**
     * 取消日结审核信息
     *
     * @param verifyId       日结审核主键
     * @param modifiedUserId 修改用户外键
     * @return
     * @author LiCongLu
     * @date 2020-02-21 14:13
     */
    @Update(" update charge_settle set as_verify = 0,verify_id = NULL,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where verify_id = #{verifyId} and unmodified = 0 and deleted = 0 ")
    void deletedForCancellationVerify(@Param("verifyId") Integer verifyId, @Param("modifiedUserId") Integer modifiedUserId);

    /**
     * 按照主键集合获取费用结算信息
     *
     * @param businessCode 业务编码
     * @param settleIds    结算费用ID集合
     * @return
     * @author ZhangLiRui
     * @date 2020/4/16 13:47
     */
    @SelectProvider(type = ChargeSettleProvider.class, method = "getPayTypeBySettleIds")
    @ResultType(String.class)
    String getPayTypeBySettleIds(@Param("businessCode") String businessCode, @Param("settleIds") ArrayList<Integer> settleIds);

    /**
     * 设置结算打印发票
     *
     * @param businessCode   业务编码
     * @param settleIds      结算集合
     * @param invoiceId      发票主键
     * @param modifiedUserId 修改人
     * @return
     * @author LiCongLu
     * @date 2020-05-14 09:13
     */
    @SelectProvider(type = ChargeSettleProvider.class, method = "updateForInvoice")
    void updateForInvoice(@Param("businessCode") String businessCode, @Param("settleIds") ArrayList<Integer> settleIds, @Param("invoiceId") Integer invoiceId, @Param("modifiedUserId") Integer modifiedUserId);

    /**
     * 设置作废发票
     *
     * @param businessCode   业务编码
     * @param invoiceId      发票主键
     * @param modifiedUserId 修改人
     * @return
     * @author LiCongLu
     * @date 2020-05-28 16:05
     */
    @SelectProvider(type = ChargeSettleProvider.class, method = "updateForInvoiceCancellation")
    void updateForInvoiceCancellation(@Param("businessCode") String businessCode, @Param("invoiceId") Integer invoiceId, @Param("modifiedUserId") Integer modifiedUserId);

    /**
     * 按照结算主键批量获取结算列表
     *
     * @param businessCode 业务编码
     * @param settleIds    结算主键集合
     * @return
     * @author LiCongLu
     * @date 2020-05-14 09:43
     */
    @SelectProvider(type = ChargeSettleProvider.class, method = "listChargeSettleViewBySettleIds")
    ArrayList<ChargeSettleViewItem> listChargeSettleViewBySettleIds(@Param("businessCode") String businessCode, @Param("settleIds") ArrayList<Integer> settleIds);
}